import manager from './manager'
import config from './config'
import CustomCommandConfig from './command'
import CustomEventConfig from './event'

const Registry = function({ id, parent }) {
  // 初始化控件,并注册到仓库
  manager.Registry({ id, parent })
  manager.MakeCurrent(id)
}

// 初始化
const Initialize = function() {
  const core = manager.CurCore()
  // const diagram = manager.CurDiagram()
  // 注册自定义命令
  core.fastRegCommand(CustomCommandConfig)
  // 注册自定义事件
  core.fastRegCustomEventFunc(CustomEventConfig)
}

// 卸载和清理
const UnInitialize = function() {
  // 释放所有的ocx内存
  manager.release()
}

// 获取Core对象
const GetCore = function() {
  return manager.CurCore()
}

const GetDiagram = function() {
  return manager.CurDiagram()
}

export default {
  Registry,
  Initialize,
  UnInitialize,
  GetCore,
  GetDiagram,
  Config: config
}
